<?php
    class Zendvn_Acl_Acl extends Zend_Acl
    {
        public function __construct(){
            // Khai bao cac nhom quyen(role)
            $this->addRole(new Zend_Acl_Role('guest'));
            $this->addRole(new Zend_Acl_Role('mod'), 'guest');
            $this->addRole(new Zend_Acl_Role('smod'), 'mod');
            $this->addRole(new Zend_Acl_Role('admin'), 'smod');
            
            // Khai bao cac resources cho module Admin
            $this->addResource(new Zend_Acl_Resource('dtkcp:index'));
            $this->addResource(new Zend_Acl_Resource('dtkcp:agent'));
            $this->addResource(new Zend_Acl_Resource('dtkcp:business'));
            $this->addResource(new Zend_Acl_Resource('dtkcp:collaborator'));
            $this->addResource(new Zend_Acl_Resource('dtkcp:customer'));
            $this->addResource(new Zend_Acl_Resource('dtkcp:invite'));
            $this->addResource(new Zend_Acl_Resource('dtkcp:order'));
            $this->addResource(new Zend_Acl_Resource('dtkcp:user'));
            
            // Khai bao cac resources cho module Default
            $this->addResource(new Zend_Acl_Resource('default:index'));
            $this->addResource(new Zend_Acl_Resource('default:about'));
            $this->addResource(new Zend_Acl_Resource('default:customer'));
            $this->addResource(new Zend_Acl_Resource('default:download'));
            $this->addResource(new Zend_Acl_Resource('default:feature'));
            $this->addResource(new Zend_Acl_Resource('default:price'));
            $this->addResource(new Zend_Acl_Resource('default:support'));
            
            // Khai bao cac resources cho module Kinhdoanh
            $this->addResource(new Zend_Acl_Resource('kinhdoanh:index'));
            $this->addResource(new Zend_Acl_Resource('kinhdoanh:business'));
            $this->addResource(new Zend_Acl_Resource('kinhdoanh:user'));
            
            // Khai bao cac resources cho module Error
            $this->addResource(new Zend_Acl_Resource('error:error'));
            
            // Cap quyen truy cap cho cac nhom
            // Guest
            $this->allow('guest', 'error:error', null);
            $this->allow('guest', 'dtkcp:index', null);
            $this->allow('guest', 'default:index', null);
            $this->allow('guest', 'default:about', null);
            $this->allow('guest', 'default:customer', null);
            $this->allow('guest', 'default:download', null);
            $this->allow('guest', 'default:feature', null);
			$this->allow('guest', 'default:price', null);
            $this->allow('guest', 'default:support', null);
            $this->allow('guest', 'kinhdoanh:index', null);
            
            // Mod
            $this->allow('mod', 'kinhdoanh:business', null);
            $this->allow('mod', 'kinhdoanh:user', null);
            
            // SMod
            $this->allow('smod', 'dtkcp:business', null);
            $this->allow('smod', 'dtkcp:agent', null);
            $this->allow('smod', 'dtkcp:collaborator', null);
            $this->allow('smod', 'dtkcp:user', array('profile','changepassword','success'));
            
            // Admin
            $this->allow('admin', 'dtkcp:index', null);
            $this->allow('admin', 'dtkcp:agent', null);
            $this->allow('admin', 'dtkcp:business', null);
            $this->allow('admin', 'dtkcp:collaborator', null);
            $this->allow('admin', 'dtkcp:customer', null);
            $this->allow('admin', 'dtkcp:invite', null);
            $this->allow('admin', 'dtkcp:order', null);
            $this->allow('admin', 'dtkcp:user', null);
        }
    }
